package com.ychs.dpmms.service;

import com.ychs.dpmms.dao.CapacityMapper;
import com.ychs.dpmms.dao.StateMapper;
import com.ychs.dpmms.entity.Capacity;
import com.ychs.dpmms.util.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * copyright(c)2021 YYB.ALL rights Reserved
 * <p>
 * 描述:
 *
 * @author 原玉波
 * @version 1.0
 * @date 2021/9/5
 */
public class CapacityService implements IBaseService<Capacity>{
    //slf4j日志对象
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    //引入mapper
    @Resource
    private CapacityMapper mapper;

    /**
     * 添加记录
     *
     * @param capacity 记录对象
     * @return 是否添加成功
     */
    @Override
    public boolean add(Capacity capacity) {
        boolean result = mapper.insert(capacity) == Constants.UPDATE_SUCCESS;
        return result;
    }

    /**
     * 修改记录
     *
     * @param capacity 记录对象
     * @return 是否修改成功
     */
    @Override
    public boolean modify(Capacity capacity) {
        boolean result = mapper.update(capacity) == Constants.UPDATE_SUCCESS;
        return result;
    }

    /**
     * 删除记录
     *
     * @param id 该记录的id
     * @return 是否删除成功
     */
    @Override
    public boolean remove(int id) {
        boolean result = mapper.delete(id) == Constants.UPDATE_SUCCESS;
        return result;
    }

    /**
     * 按照条件查询所有记录
     *
     * @param conditions 条件
     * @return 记录对象
     */
    @Override
    public List<Capacity> search(Map<String, Object> conditions) {
        List<Capacity> capacities = mapper.select(conditions);
        return capacities;
    }

    /**
     * 按照id查询记录
     *
     * @param id 记录的id
     * @return 记录对象
     */
    @Override
    public Capacity searchById(int id) {
        Capacity capacity = mapper.selectById(id);
        return capacity;
    }

    /**
     * 按照条件查询记录总数
     *
     * @param conditions 条件
     * @return 符合条件的记录总数
     */
    @Override
    public int searchTotalNumber(Map<String, Object> conditions) {
        int count = mapper.selectTotalNumber(conditions);
        return count;
    }
}
